import os  


# 遍历指定目录，显示目录下的所有文件名
def eachFile(filepath):
    files = []
    pathDir = os.listdir(filepath)
    for allDir in pathDir:
        child = os.path.join('%s%s' % (filepath, allDir))
        files.append(child)
        # print(child)# .decode('gbk')是解决中文显示乱码问题
        return files

def eachFileNme(filepath):
    pathDir = os.listdir(filepath)
    return pathDir

def eachFileNmeNoExtensions(filepath, filetype):
    pathDir = []
    pathDirraw = os.listdir(filepath)
    for i in pathDirraw:
        pathDir.append(i.replace("." + filetype, ''))
    return pathDir


if __name__ == "__main__":
    # get_filename(r'F:\chen\pythonworkspace\PythonGithub\TestFile\', "xml")
    # SyntaxError: EOL while scanning string literal,最后一个字符是\的话
    print(eachFileNmeNoExtensions(r"F:\chen\pythonworkspace\PythonGithub\TestFile", "xml"))
